/*
Contains:
	derived procs from /obj/item
	declared items
	book procs
*/

book
	parent_type=/obj/item

	icon='books.dmi'

	Write()
		contents=new/list()
		..()

	Read()
		if(!spells) spells=list()
		..()

	New()
		if(!spells) spells=list()
		..()

	var
		spell/list/spells
		capacity	=6
		length		=6

	LeftClick(mob/clicker, loc, control, params)

		if(clicker.BOOK == src)
			unequip_from(clicker)
			return

		else if(clicker.BOOK != null && clicker.BOOK != src)
			var/book/b = clicker.BOOK
			b.suffix=null
			b.overlays = new/list()

		equip_to(clicker)

	equip_to(mob/reader)
		. = ..(reader)
		if(.)
			reader.BOOK = src
			if(isplayer(reader))
				var/player/p = reader
				p.draw_hotkeys()

	unequip_from(mob/reader)
		..(reader)
		reader.BOOK = null
		if(isplayer(reader))
			var/player/p = reader
			p.clear_hotkeys()
			winshow(p,"book",0)

	is_equipped(mob/person)
		return person.BOOK == src

	proc
		check_spells()
			for(var/s= 1 to capacity)
				if(spells[s] == null)
					return s
			return 0

	//item declarations
	Test_Book
		icon_state="test"
		capacity	=5
		length		=6
		desc 		="A book forged from the elements of basicness."
		rows		=3

	Epic_Book
		icon_state="test"
		capacity	=10
		length		=30
		desc 		="An epic-class book written with epic ink by an epic priest."
		rows		=3